<template>
    <div class="width-full">
        <div class="fc-header">
            <div class="fc-wuserheader" v-if="headerMsg && Object.keys(headerMsg).length > 0">
                <!--店铺信息-->
                <img v-if="headerMsg && headerMsg.belongUserInfo && headerMsg.belongUserInfo.photo" @click="$emit('clickHeaderImg',headerMsg.belongUserInfo.userId)" class="fc-userheader"
                     :src="headerMsg.belongUserInfo.photo" alt="">
                <img v-else class="fc-userheader" :src="staticImageUrl('images/look/default_userheader.png')" alt="">
                <span class="fc-userheader-des" v-if="headerMsg.belongUserInfo && headerMsg.belongUserInfo.userName">
                    <span>{{headerMsg.belongUserInfo.userName}}</span>
                    <span class="userheader-des" v-if="false">这个功能还没做暂时不显示</span>
                </span>
                <span class="fc-swiper-wpagination">
                    <!--好看没有定位功能-->
                    <span class="fc-swiper-pagination"
                          v-if="headerMsg.mediaType == 1 && headerMsg.mediaContents[0].url && headerMsg.mediaContents.length > 0">
                        <span id="activeIndex">{{headerMsg.nowSwiperIndex}}</span>/{{headerMsg.mediaContents.length}}
                    </span>
                </span>
                <div class="fc-attention" v-if="!headerMsg.queryUserBehaviorInfo.hadConcernedUser"
                     @click="handleAttention()">
                    <img class="fc-attention-img" src="../../../assets/images/common/icon_white_add.png" alt="">
                   关注
                </div>
                <transition name="attention" leave-active-class="animated fadeOut">
                    <div v-if="showAlreadyText" class="fc-attention looking-already-attention">已关注</div>
                </transition>
            </div>
        </div>
        <p class="header-msg" @click="$emit('clickTitle',headerMsg)" v-if="headerMsg.interactModel && headerMsg.interactModel.title">
            #{{headerMsg.interactModel.title}}#
        </p>
        <p class="look-index-mood-text positionR" v-if="headerMsg.mediaComment">
            <span ref="mediaCommentTextId" class="media-comment-text" :class="{'one-line-ellepsis':!headerMsg.showMoreLine}">
                {{headerMsg.mediaComment}}
                <img class="show-more-line transform180"
                     @click="headerMsg.showMoreLine=!headerMsg.showMoreLine"
                     v-if="headerMsg.showMoreLine && mediaCommentText(headerMsg.nowSwiperIndex)"
                     src="../../../assets/images/common/show_more.png" alt="">
            </span>
            <img class="show-more-line" v-if="!headerMsg.showMoreLine && mediaCommentText(headerMsg.nowSwiperIndex)" @click="headerMsg.showMoreLine=!headerMsg.showMoreLine" src="../../../assets/images/common/show_more.png" alt="">
        </p>
    </div>
</template>

<script>
    export default {
        name: "userMsg",
        props: {
            headerProp: Object,
        },
        data() {
            return {
                showAlreadyText:false,//已关注的字样的动画
                headerMsg: {
                    // belongUserInfo: {
                    //     userId: 0,
                    //     photo: '',
                    //     userName: '',
                    // },
                    // mediaType:0,//表示视频，1表示轮播图
                    // mediaContents:[
                    //     {url:''}
                    // ],
                    // nowSwiperIndex:1,//swiper现在的index
                    //showMoreLine:false,//是否显示更多文字
                    //commentTitle:'',
                },
            }
        },
        mounted(){
            this.headerMsg = Object.assign({},this.headerMsg,this.headerProp);
            
        },
        methods: {
            handleAttention(){
              this.headerMsg.queryUserBehaviorInfo.hadConcernedUser = true
              this.$emit('doAttention',0,this.headerMsg.belongUserInfo.userId,this.headerMsg.nowSwiperIndex,this.showHide)
            },
            toUserInfo(userId) {
                /*传入被浏览者userId*/
                this.$router.push({path: '/to/user/info', query: {'visitId': userId,self:false}});
            },
            mediaCommentText(index){
                let that = this;
                let screenWidth = document.documentElement.clientWidth;
                let isShow = screenWidth / 375 * $(that.$refs.mediaCommentTextId).width() / 100  > 3.05;
                return isShow;
            },
            showHide(){
                this.showAlreadyText = true;
                setTimeout(()=>{
                    this.showAlreadyText = false
                },300);
            }
        },
        watch:{
            headerProp(val){
                this.headerMsg = Object.assign({},this.headerMsg,val);
            }
        }
    }
</script>

<style scoped lang="scss">
    .fc-header {
        color: #000;
        padding: .06rem 0;
        width: 100%;
        z-index: 2;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }

    .fc-wuserheader {
        height: .32rem;
        display: -webkit-flex;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        color: #fff;
        margin-bottom: .1rem;
    }

    .fc-userheader {
        width: .32rem;
        height: .32rem;
        border-radius: 50%;
        background: #fff;
        margin-right: .1rem;
    }
    .header-msg{
        /*padding-bottom: .02rem;*/
        padding-bottom: .1rem;
    }
</style>